package com.spinus.spinusdemo;

/**
 * @author huangding
 * @description 错误码
 * @date 2018/9/28 15:24
 */
public enum JsonResultErrorEnum {

    /**
     * 成功
     */
    SUCCESS("0", "success"),

    /**
     * 优惠券以6000开始
     */
    COUPON_NOT_ENABLE_TIME("6000", "未到优惠券领取时间"),
    COUPON_NOT_CUT_OFF_TIME("6001", "优惠券领取已截止"),
    COUPON_NOT_PUBLISH_COUNT("6002", "优惠券已领完"),
    COUPON_RULE_VERIFICATION_ERROR("6003", "优惠券规则验证失败"),
    COUPON_NOT_TEMPLATE_ERROR("6004", "无该优惠券模板"),
    COUPON_SAVE_ERROR("6005", "保存优惠券信息出错，请重试"),
    COUPON_STATUS_ERROR("6006", "优惠券已过期"),
    COUPON_NOT_USE("6007", "优惠券非未使用状态"),
    COUPON_NOT_USE_TIME("6008", "未到优惠券使用时间"),
    COUPON_EXPIRED_USE_TIME("6009", "优惠券已过期"),
    COUPON_UPDATE_TEMPLATE_ERROR("6010", "发行数量不能小于之前的数量，截止时间不能小于之前设置的时间"),
    COUPON_SELLER_NULL("6011", "对应商家不存在该优惠券"),
    COUPON_EXPIRED_USE_OK("6012", "优惠券已使用"),
    COUPON_EXPIRED_LOCK("6013", "优惠券已冻结"),

    /**
     * 接口以7000开始
     */
    OPEN_NOT_APP_ID("7001", "无对应商家"),
    OPEN_NOT_METHOD("7002", "无对应接口"),
    OPEN_SIGN_WRONGFUL("7003", "签名不合法"),
    OPEN_FORMAT_ERROR("7004", "参数格式错误"),
    OPEN_NOT_PARAMETER("7005", "必填参数不完整,或者参数格式错误"),
    OPEN_NOT_COUPON("7006", "不存在该优惠券ID，请检查传入参数"),
    OPEN_TIMESTAMP_OUT("7007", "请求时间超时"),
    OPEN_NOT_DATA("7008", "请求参数不存在"),
    OPEN_ONT_TEL_PLATE("7009", "请输入正确手机号码，或者车牌号"),
    OPEN_UNLOCK_ERROR("7010", "优惠券解锁失败"),
    /**
     * 用户以8000开始
     */
    CUSTOMER_NOT_NULL("8000", "不存在该用户"),
    CUSTOMER_PHONE_ERROR("8001", "请输入正确的手机号码"),
    CUSTOMER_SMS_NOTHING("8002", "短信发送失败，请稍后重试"),
    CUSTOMER_SMS_NOT_CORRECT("8003", "请输入正确的手机号码"),
    CUSTOMER_PHONE_IS_REGISTERED("8004", "该手机号码已经被注册了，请直接登录"),
    CUSTOMER_SMS_IS_SENT("8005", "验证码30分钟内有效，请不要重复获取"),
    CUSTOMER_SECURITY_CODE("8006", "验证码错误，请重试"),
    CUSTOMER_RETRY("8007", "请稍后重试"),
    CUSTOMER_OPENID_NOT("8008", "非法注册"),
    CUSTOMER_NOT_CAR("8009", "请输入正确的车牌号码,或者大写字母"),
    CUSTOMER_MISUSE("8010", "非法操作"),
    CUSTOMER_CAR_REPETITION("8011", "您已经绑定过此车牌"),
    CUSTOMER_BINDING_ELSE_CAR("8012", "您已经绑定过其他车牌,请联系客服"),
    CUSTOMER_CAR_ELSE_BINDING("8013", "该车牌已被绑定过，请联系客服"),

    /**
     * 商户以9000开始
     */
    SELLER_VERIFICATION_USER_EXIST("9000", "该核销员已存在"),
    ;

    private String msg;
    private String code;

    JsonResultErrorEnum(String code, String msg) {
        this.msg = msg;
        this.code = code;
    }

    public static JsonResultErrorEnum N(String code) {
        for (JsonResultErrorEnum jsonResultErrorEnum : values()) {
            if (jsonResultErrorEnum.getCode().equals(code)) {
                return jsonResultErrorEnum;
            }
        }
        return null;
    }


    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
